package service

import (
	"choujiang/common/db"
	"choujiang/common/models"
)

func UpdateUserAddress(receiver string, phone string, province int64, city int64, area int64, address string, userId int64) error {
	_, err := db.MysqlEngine.Exec("update user_extra set receiver = ?, phone = ?, province = ?, city = ?, area = ?, address = ? where user_id = ?", receiver, phone, province, city, area, address, userId)
	if err != nil {
		return err;
	}
	return nil
}

func GetUserAddress(userId int64) (*model.UserExtra, error) {
	userExtra := new(model.UserExtra)
	_, err := db.MysqlEngine.Where("user_id = ?", userId).Get(userExtra)
	return userExtra, err
}
